/****************************************************************************
 *
 *                Admin Over Im
 *
 ****************************************************************************
 *
 *  <Copyright>
 *    Copyright (C) 2008  Basov Alexander
 *
 *  <Unit> jmessage.cpp
 *   <ImplementationNotes>
 *   <PortabilityIssues>
 *   <AnticipatedChanges>
 *****************************************************************************
 *
 *  $Revision: 129 $ $Author: F0boS $
 *  $Date: 2008-03-10 19:59:35 +0300 (Вск, 10 Мар 2008) $
 *****************************************************************************/

#include <cerrno>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

#include "jmessage.h"

/**
 *
 *  <Subprogram> err
 *    <Unit>
 *    <ImplementationNotes> prints error message to stderr
 */

using namespace std;

void err (string msg)
{
  cerr << endl << msg << " : " << strerror (errno) << endl;
}

JMessage::JMessage (const xmlChar **attributes)
{
  while (attributes != NULL) {
    printf("attr: %s\n", attributes[++i]);
    printf("value: %s\n", attributes[++i]);
  }
}

void JMessage::setFrom (const std::string data)
{
  from = data;
}

void JMessage::setTo (const std::string data)
{
  to = data;
}

void JMessage::setId (const std::string data)
{
  id = data;
}

void JMessage::setType (const std::string data)
{
  if (data == "chat" ||
      data == "error" ||
      data == "groupchat" ||
      data == "headline" ||
      data == "normal")
  type = data;
  else err ("Wrong type attribute");
}

void JMessage::setLang (const std::string data)
{
  lang = data;
}

void JMessage::setSubject (const std::string data)
{
  subject = data;
}

void JMessage::setThread (const std::string data)
{
  thread = data;
}

void JMessage::setBody (const std::string data)
{
  body = data;
}
